Skip to content

Rework handling of panning to identified features - #4591

Open
uclaros wants to merge 10 commits into
masterfrom
bugfix/better-jump-to
Open

Rework handling of panning to identified features#4591
uclaros wants to merge 10 commits into
masterfrom
bugfix/better-jump-to

Conversation

@uclaros

@uclaros uclaros commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Plan A

This PR is a rework on how we jump to geometries. It was initially just a way to mitigate a GEOS crash when identifying self-overlapping multipart geometries, but quickly evolved!

Plan B

If this is too much for a last minute change, we can avoid hitting the geos bug by slightly modifying the current approach: Perform bounding box intersections instead of geometry intersections.

diff --git a/app/inpututils.cpp b/app/inpututils.cpp
index b5573eb3..02a874e8 100644
--- a/app/inpututils.cpp
+++ b/app/inpututils.cpp
@@ -330,13 +330,12 @@ QPointF InputUtils::relevantGeometryCenterToScreenCoordinates( const QgsGeometry
 
   const QgsRectangle currentExtent = mapSettings->mapSettings().visibleExtent();
 
-  // Cut the geometry to current extent
-  const QgsGeometry currentExtentAsGeom = QgsGeometry::fromRect( currentExtent );
-  const QgsGeometry intersectedGeom = geom.intersection( currentExtentAsGeom );
+  // Cut the geometry extent to current extent
+  const QgsRectangle intersectedExtent = currentExtent.intersect( geom.boundingBox() );
 
-  if ( !intersectedGeom.isEmpty() )
+  if ( !intersectedExtent.isEmpty() )
   {
-    target = QgsPoint( intersectedGeom.boundingBox().center() );
+    target = QgsPoint( intersectedExtent.center() );
   }
   else
   {

This will change the existing behavior, eg identifying C shaped geometry that is partially visible will not recenter the map canvas to the center of the visible part of the geometry, but to the visible part of the geom bbox.

Testing notes:

  • need to test all Geometries that we support (Points, Lines, Polygons and it's multi variants)

uclaros added 7 commits July 10, 2026 11:44
We will use it to jump to the highlighted feature once we know
the available area of the map that is not covered by the panel
- Use the renamed previewPanelHeight property instead of signal params
- Move all highlighting and form opening to a identifyFeature()
- Don't pan if whole feature is near visible map center
- Center feature to visible map if it fits
- Center clicked location to visible map if whole does not fit
- Add method to calculate the map extent required for a geometry to
  fit the visible part of the map canvas when covered by a drawer
- Use animated zoom when identifying features from a list and not on map
@Withalion

Copy link
Copy Markdown
Collaborator

might help resolve #3845 as well

@Withalion Withalion left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! It would be great to rebase on current master as well since some time passed.

Comment thread app/qml/map/MMMapCanvas.qml Outdated
Comment thread app/qml/map/MMMapCanvas.qml Outdated
Comment thread app/qml/map/MMMapCanvas.qml
Comment thread app/qml/map/MMMapController.qml Outdated
// Holds the map coordinates of the point the user identified. NaN if identify was triggered from list of features
property point identifyLocation: Qt.point(NaN, NaN)

signal featureIdentified( var pair, var point )

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
signal featureIdentified( var pair, var point )
signal featureIdentified( FeatureLayerPair pair, qgsPoint clickedPoint )

It's about time we expose FeatureLayerPair & QgsPoint to QML properly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well yes, but do you think this PR is the proper place to do it?

Comment thread app/test/testutilsfunctions.cpp
}
}

void TestUtilsFunctions::testWhereToPanWhenIdentifying()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we check here that the scale has not changed as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InputUtils::whereToPanWhenIdentifying() does not perform the panning, it only finds out the point that needs to be panned to.
It does not modify the settings at all.
Maybe better const' the InputMapSettings *` param to clarify the intent?

}
}

void TestUtilsFunctions::testDrawerCompensatedExtent()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As well here I would have case for:

  • when the map is just panned
  • when feature is bigger then current extent, so the map zooms out
  • when feature is smaller then current extent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only tests the extent calculation when compensating for the drawer height.

Testing the actual panning to and zooming to would be a completely different case.

Comment thread app/test/testutilsfunctions.cpp Outdated
Comment thread app/test/testutilsfunctions.cpp Outdated
@Withalion Withalion modified the milestones: 2026.4.0, 2026.5.0 Aug 25, 2026
@Withalion

Copy link
Copy Markdown
Collaborator

@uclaros can you please imrpove the description of this issue. What's happening, what's the issue. Mostly for testers to understand the issue better.

@Withalion Withalion removed this from the 2026.5.0 milestone Aug 27, 2026
@github-actions

Copy link
Copy Markdown

📦 Build Artifacts Ready

OS Status Build Info Workflow run
macOS Build 📬 Mergin Maps 72391 dmg Expires: 25/11/2026 #7239
linux Build Build failed or not found. #7265
win64 Build 📬 Mergin Maps 64411 win64 Expires: 25/11/2026 #6441
Android Build 📬 Mergin Maps 854911 APK [armeabi-v7a] Expires: 25/11/2026 #8549
📬 Mergin Maps 854911 APK [armeabi-v7a] Google Play Store #8549
Android Build 📬 Mergin Maps 854951 APK [arm64-v8a] Expires: 25/11/2026 #8549
📬 Mergin Maps 854951 APK [arm64-v8a] Google Play Store #8549
iOS Build 📬 Build number: 26.08.949111 #9491

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants